<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:h="http://java.sun.com/jsf/html"  
				xmlns:f="http://java.sun.com/jsf/core" 
                xmlns:p="http://primefaces.org/ui"
				lang="pt" 
				template="/common/decorators/arearestrita/template.xhtml">
  
	<ui:define name="body"> 	 
		<h1 class="ui-widget-header" style="margin-left: 10px"><span>Cadastro de Mesas</span></h1>
		<h:form id="mesaForm" prependId="false">  
            
            <p:panel header="Mesas" styleClass="painelComum" style="width: 700px">  
				<p:dataTable id="mesas"  
								value="#{mesaBean.listMesa}" 
								var="mesa" 
								width="100%"
                                paginator="true" 
                                paginatorPosition="bottom"
                                rows="10"    >
                    
                   	<p:column>
						<f:facet name="header">Nome</f:facet> 
						<h:outputText value="#{mesa.nome}" /> 
					</p:column> 
                    
                   	<p:column>
						<f:facet name="header">Status</f:facet> 
						<h:outputText value="Ativa"  rendered="#{mesa.status}"/>  
						<h:outputText value="Inativa"  rendered="#{!mesa.status}"/> 
					</p:column> 
					 
                   	<p:column> 
						<p:commandLink action="#{mesaBean.alterStatus}" update="mesaForm"> 
							<h:graphicImage value="/common/images/remover-icon.png" style="border:0px;" rendered="#{mesa.status}"/>
							<h:graphicImage value="/common/images/ativo_16x16.png" style="border:0px;" rendered="#{!mesa.status}"/>
							<f:setPropertyActionListener value="#{mesa}" target="#{mesaBean.mesa}" />
						</p:commandLink> 
						<p:commandLink title="Editar" update="mpMesaForm" oncomplete="mpMesa.show()">  
							<f:setPropertyActionListener value="#{mesa}" target="#{mesaBean.mesa}" /> 
							<h:graphicImage value="/common/images/alter_16x16.png" style="border:0px;"/>
						</p:commandLink>  
					</p:column> 	
				</p:dataTable> 
				<p:commandButton value="Nova Mesa"    
				                 update="mpMesaForm"
				                 styleClass="buttonClass"  
				                 oncomplete="mpMesa.show();"> 
						<f:setPropertyActionListener value="#{null}" target="#{mesaBean.mesa}" /> 
				</p:commandButton>                   
            </p:panel>     
            
		</h:form> 
		<p:dialog header="Mesa" autosized="true" modal="true" widgetVar="mpMesa" width="300" showEffect="explode" hideEffect="explode"> 
			<h:form id="mpMesaForm"> 
				<p:panel>
					<h:panelGrid columns="2">  
						<h:outputText value="Nome" styleClass="labelClass"/>
						<p:inputText value="#{mesaBean.mesa.nome}" id="nome" />
						
						<p:commandButton value="Salvar"  action="#{mesaBean.save}" update="mesas" onclick="mpMesa.hide();" ajax="false"/>
						<p:commandButton value="Cancelar" onclick="mpMesa.hide();"/>
					</h:panelGrid> 
				</p:panel>
			</h:form>  
         </p:dialog>
            
	</ui:define> 	
</ui:composition>